<div>





{{$this->Form->create('WxMsg',array('class'=>'form-horizontal','onsubmit'=>'return saveWxMsg(this);','role'=>'form'))}}

	<div role="tabpanel">

  <div class="tab-content" style="padding-top:10px;">
    <div role="tabpanel" class="tab-pane active" id="msg-info">
    
		
    	{{if $id}}
			<div class="form-group">
				<label class="col-sm-2 control-label" for="WxMsgName">存储选项</label>
				<div class="col-sm-9 controls">
					<div class="btn-group" data-toggle="buttons">
					  <label class="btn btn-default active">
					    <input type="radio" name="data[WxMsg][new]" value="0" autocomplete="off" checked> 覆盖原图文
					  </label>
					  <label class="btn btn-default" onclick="$('#WxMsgThumbMediaId').val('');$('#WxMsgCoverimg').val('');">
					    <input type="radio" name="data[WxMsg][new]" value="1" autocomplete="off"> 保存为新的图文
					  </label>
					</div>
				</div>
			</div>
		{{/if}}
		
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMsgName">图文标题 <span style="color:red">*</span></label>
			<div class="col-sm-9 controls">
				{{$this->Form->hidden('id')}}
				<input type="hidden" name="mid" value="{{$mid}}"><input type="hidden" name="idx" value="{{$idx}}">
				{{$this->Form->hidden('date',array('default'=>date('Y-m-d')))}}
				{{$this->Form->input('name',array('class'=>'form-control','required'=>'required','div'=>false,'label'=>false))}}
			</div>
		</div>
		
		


		<div class="form-group" id="divWxMsgSummary">
			<label class="col-sm-2 control-label" for="WxMsgSummary">图文摘要</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('summary',array('class'=>'form-control','div'=>false,'label'=>false,'rows'=>'2','placeholder'=>'请输入图文消息摘要'))}}
			</div>
		</div>
 		
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMsgCoverimg">封面图片</label>
			<div class="col-sm-10 controls select" style="position: relative;padding-right: 200px;">
{{if !empty($_REQUEST['mid'])}}
				<div class="form-inline">
					{{$this->Form->input('thumb_media_id',array('class'=>'form-control','required'=>'required','type'=>'text','style'=>'width:260px;','readonly'=>'readonly','div'=>false,'label'=>false))}}
					<a href="javascript:void(0)" class="btn btn-primary" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&m=image&inajax=1&manage_wxid='+$('#WxMsgWxId').val(),{'selector':'#wechat-msg-mine-list','zIndex':1000150,width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxMsgThumbMediaId').val( $(this).data('mid') ); $('#WxMsgCoverimg').val( $(this).data('url') );$dialog.modal('hide');}) } });" >从微信素材选择</a>
				</div>
				<div>
					<label>{{$this->Form->input('show_cover_pic',array('type'=>'checkbox','value'=>1,'div'=>false,'label'=>false))}}
					正文中显示封面图片</label>
				</div>
				<p style="color:red;">提示：从微信素材中心选择图片素材作为封面图片后，无需再次上传。</p>
				{{$this->Swfupload->load('coverimg',array(
				'label'=>false,'modelClass'=>'WxMsg',
				'upload_limit'=>1,'isadmin' => false, 'upload_success_addon' => 'WxMsgCoverimgUploaded',
				'remote_type' => 'wechat',
				'js_loaded' => true,
				'input_type' => 'hidden',
				'file_types'=> '*.jpg;*.gif;*.png;*.bmp',
				'isadmin'=>false
				))}}
{{elseif empty($_REQUEST['mid'])}}
				<div class="swfupload-control" style="margin-top: 2px;" >
					{{$this->Form->input('coverimg',array('type'=>'text','class'=>'form-control','placeholder'=>"您可以设计、选择、上传封面图片或者直接输入图片URL地址",'div'=>false,'label'=>false))}}
				<section style="margin-top: 2px;">
        			<a data-kind="20" style="float:left;height:34px;font-size: 14px;line-height:34px;padding:0 10px;" data-access="2221abf77d614e5d8bc1a0124378cc6a" data-zIndex="9000050" href="javascript:void(0)" class="btn btn-primary showtooltip chuangkit-design-button" data-toggle="tooltip" title="宽900*高500，封面图设计由“创客贴”提供技术支持">设计封面首图</a>
					<a data-kind="40" style="float:left;height:34px;font-size: 14px;line-height:34px;padding:0 10px;margin:0 5px;" data-access="2221abf77d614e5d8bc1a0124378cc6a"  data-zIndex="9000050" href="javascript:void(0)" class="btn btn-primary showtooltip chuangkit-design-button" data-toggle="tooltip" title="宽200*高200，封面图设计由“创客贴”提供技术支持">设计封面次图</a>
        			<a href="javascript:void(0)" style="float:left;height:34px;font-size: 14px;line-height:34px;padding:0 10px;margin:0 5px 0 0;"  class="btn btn-primary" onclick="publishController.open_dialog('/uploadfiles/mine?&type=select&modelclass=WxMsg&fieldname=coverimg&inajax=1',{'selector':'#my-file-list','zIndex':1000150,width:900,title:'选择封面',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxMsgCoverimg').val( $(this).data('url') );$dialog.modal('hide');}) } });" >选择封面</a>
					
        			<span id="spanButtonPlaceholder_WxMsgCoverimg"></span>
        		</section>
        		{{$this->Form->hidden('thumb_media_id')}}
        		<div>
					<label>{{$this->Form->input('show_cover_pic',array('type'=>'checkbox','value'=>1,'div'=>false,'label'=>false))}}
					正文中显示封面图片</label>
				</div>
				
        				<div id="fsUploadProgress_WxMsgCoverimg"></div>
						<div class="upload-filelist row" id="fileuploadinfo_WxMsgCoverimg">
							
						</div>
				</div>
<script>
			 $(function(){
			    	$('.chuangkit-design-button').click(function(){
			    		window.localStorage._135content = current_editor.getContent();
			    		autoSavedraft();
			    	});
			    });
			    			
function uploadSuccess_WxMsgCoverimg(file, serverData) {
				try {
					var progress = progress_list[file.id] ;
					progress.setComplete();
					if (serverData === " ") {
						this.customSettings.upload_successful = false;
					} else {
						var data=eval("(" + serverData + ")");
						if(data.status==1||data.status=='SUCCESS'){
							this.customSettings.upload_successful = true;
							$("#WxMsgCoverimg").val(data.fspath);
                            if(typeof WxMsgCoverimgUploaded == "function") {
                                WxMsgCoverimgUploaded(data);
                            }$("#fileuploadinfo_WxMsgCoverimg").html(data.message);
						}
                        else{
                            if(data.error) {
            					alert(data.error);
            				}
                        }
					}
				} catch (e) {
					alert(serverData);
				}
			}var swfu_WxMsgCoverimg;
$(function () {
	swfu_WxMsgCoverimg = new SWFUpload({
		upload_url: "/uploadfiles/upload",	
		file_post_name: "coverimg",
		file_size_limit : "2 MB",
		file_types : "*.jpg;*.gif;*.png;*.bmp",
		file_types_description : "All Files",
		file_upload_limit : 0,
		file_queue_limit : 1,
		post_params : {
			"PHP_SESSION_ID" : "{{$this->Session->id()}}",
			"file_post_name" : "coverimg",
			"file_model_name":"WxMsg",
			"no_db":"0",
			'no_thumb':1,
			"data_id":"",
			"item_css":"",
			"save_folder":"",
			"return_type":"json",
			"remote_type":"oss"
		},
		
		button_image_url : "/img/zh-cn/uploadbutton.png",
// 		button_text ： "Upload file",
// 		button_text_style : "color: #000000; font-size: 16pt;",
		button_placeholder_id : "spanButtonPlaceholder_WxMsgCoverimg",
		button_width: 110,
		button_height: 35,
		
			
		flash_url : "/js/swfupload/swfupload.swf",
		flash9_url : "/js/swfupload/swfupload_fp9.swf",
		
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		
		swfupload_preload_handler : preLoad,
		swfupload_load_failed_handler : loadFailed,
		swfupload_loaded_handler : loadSuccess,
		
		upload_start_handler : uploadStart,upload_progress_handler : uploadProgress,upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess_WxMsgCoverimg,
		upload_complete_handler : uploadComplete,
		custom_settings : {
			progress_target : "fsUploadProgress_WxMsgCoverimg",
			upload_successful : false,
			auto_start : true
		},
		debug: false
	});
	swfu_array[swfu_array.length] = swfu_WxMsgCoverimg;
});
</script>
{{/if}}	
			</div>			
		</div>
	
	<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMsgName">原文链接</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('content_source_url',array('class'=>'form-control','div'=>false,'label'=>false))}}
			</div>
	</div>

		
		<div class="form-group form-inline">
			<label class="col-sm-2 control-label" for="WxMsgCateId">所属分类</label>
			<div class="col-sm-9 controls select">
				{{$this->Form->input('cate_id',array('class'=>'form-control','div'=>false,'label'=>false))}}
				&nbsp;&nbsp;<a target="_blank" href="{{$this->Html->url(array('controller'=>'user_cates','action'=>'add','WxMsg'))}}">新增分类</a>
				&nbsp;&nbsp;<a href="javascript:loadUserCateOptions('#WxMsgCateId','WxMsg')" class="showtooltip" title="新增分类后，点击刷新分类，新增的会出现在选项中">刷新分类</a>
				
				&nbsp;&nbsp;<label for="WxMsgAuthor">作者</label>:	
					{{$this->Form->input('author',array('class'=>'form-control','div'=>false,'label'=>false))}}
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-2 control-label">原创与留言</label>
			<div class="col-sm-9 controls" style="padding-top: 9px;">
				<!-- <label>{{$this->Form->input('WxMsg.bk1.bit0',array('default'=>0,'value'=>1,'type'=>'checkbox','div'=>false,'label'=>false))}}
				开启原创</label> -->
				
				<label>{{$this->Form->input('WxMsg.bk1.bit1',array('default'=>0,'value'=>1,'type'=>'checkbox','div'=>false,'label'=>false))}}
				开启留言</label>
				<p>提示：未开通<!-- 原创与 -->留言功能的公众号，请勿选择是。</p>
			</div>
		</div>
		
		
		
		

{{if empty($_REQUEST['mid'])}}
		<div class="form-group">
			<label class="col-sm-2 control-label" style="padding:0 5px;">同步</label>
			<div class="col-sm-9 controls select">				
				<div>
					<p style="font-size:14px;">						
						保存时将图文直接同步到第三方（需要设置好封面图片，授权账号）
					</p>
					<?php $nums = array(); ?>
					{{loop $CurrentUser['Oauthbind'] $oauth}}
						<?php if( !in_array($oauth['source'],array('sina','wechatComp','toutiao')) ) continue; 
							if(!isset($nums[$oauth['source']])) $nums[$oauth['source']] = 0; 
							$nums[$oauth['source']] ++;
							if( $nums[$oauth['source']] <= 10 && (in_array(9,$CurrentUser['role_id']) || in_array(13,$CurrentUser['role_id'])) ) { ; }
							elseif ( $nums[$oauth['source']] <= 5 && in_array(10,$CurrentUser['role_id']) ) {;}
							elseif ( $nums[$oauth['source']] <= 2 && in_array(8,$CurrentUser['role_id']) ) {;}
							elseif ( $nums[$oauth['source']] == 1 ) {;}
							else{continue;}
						?>
						<section style="display:inline-block;font-size:20px;text-align:center;margin-right: 20px;" >
							<label>
							<input type="checkbox" {{if isset($synclogs[$oauth['oauth_openid']])}}checked="checked"{{/if}} name="data[WxMsg][sync][]" value="{{$oauth['id']}}">
							{{if $oauth['source']=='sina'}} <i style="color:red;" class="fa fa-weibo"></i> 
							{{elseif $oauth['source']=='wechatComp' }} <i  style="color:rgb(171,218,76);" class="fa fa-weixin"></i> 
							{{elseif $oauth['source']=='toutiao' }} 
								<img style="height: 25px;vertical-align: middle;" src="/img/oauth/icon-toutiao.png" title="使用今日头条账号登陆" class="showtooltip" >
							{{/if}}
							 {{$oauth['oauth_name']}}
							</label>
						</section>
					{{/loop}}
				</div>
			</div>			
		</div>		
		
{{/if}}		
    </div>
    <!-- 
    <div role="tabpanel" class="tab-pane" id="wechat-info">
    	
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMsgName">作者</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('author',array('class'=>'form-control','div'=>false,'label'=>false))}}
			</div>
		</div>
    </div> -->
  </div>

</div>

	<div id="saveSelfBtn"  class="form-group">
		<label class="col-sm-2 control-label"></label>
		<div class="col-sm-9">
			<input class="btn btn-primary" id="save-wx-msg" type="submit" value="保存文章">
				&nbsp;&nbsp;&nbsp;<a class="btn btn-default" href="javascript:void(0)" onclick="save_as_tpl();">存为个人模板样式</a>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a style="color:#E2561B;font-size: 18px;" href="javascript:void(0)" class="showtooltip" title="将直接存给对方，给自己的需要另外再保存。存给他人时，将忽略同步操作。" onclick="$('#WxMsgCreator').val('');$('#saveOtherBtn').show();$('#saveSelfBtn').hide();"><i class="fa fa-exchange"></i> 另存图文给其他用户</a>
		</div>
	</div>
	
	<div  id="saveOtherBtn" style="display:none;">
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMsgName">发送给</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('creator',array('class'=>'form-control','type'=>'text','placeholder'=>'请输入对方的135用户编号','div'=>false,'label'=>false))}}
				<p>您的用户编号是: {{$CurrentUser['id']}} ,多人协作或开放投稿时将编号告诉小伙伴们。</p>
			</div>
    	</div>
		<div class="form-group">
			<label class="col-sm-2 control-label"></label>
			<div class="col-sm-9">
				<input class="btn btn-primary" id="save-wx-msg" type="submit" value="另存图文给其他用户">
				&nbsp;&nbsp;&nbsp;<a class="btn btn-default" href="javascript:void(0)" onclick="save_as_tpl();">存为个人模板样式</a>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a style="color:#E2561B;font-size: 18px;" href="javascript:void(0)" onclick="$('#WxMsgCreator').val('');$('#saveOtherBtn').hide();$('#saveSelfBtn').show();"><i class="fa fa-save"></i> 还是存给自己</a>
			</div>
		</div>
	</div>
	<!--
	<div>
	<hr style="margin:5px;">
				<p style="font-size:13px;text-align: center;">
					
					<a href="http://www.135plat.com/wxes/pauth" title="授权公众号后，文章直接同步至微信文章素材库" target="_blank"><i  style="color:rgb(171,218,76);" class="fa fa-weixin"></i> 授权同步文章至微信公众号</a> &nbsp;&nbsp;&nbsp;
					<a href="http://www.135editor.com/oauth/sina/login" title="授权微博后，文章将同步至微博的头条文章。" target="_blank"><i style="color:red;" class="fa fa-weibo"></i> 授权同步文章到微博头条</a> &nbsp;&nbsp;&nbsp;
					<a href="http://www.135editor.com/oauth/toutiao/login" title="授权今日头条后，文章将同步至今日头条文章。" target="_blank"><img style="height: 25px;vertical-align: middle;" src="/img/oauth/icon-toutiao.png" class="showtooltip" > 授权同步文章到今日头条</a>
					 
					 <a href="http://www.135editor.com/users/index" target="_blank">授权微信公众号，绑定微博、今日头条账号，进行文章的多平台发布。</a> &nbsp;&nbsp;&nbsp;
				</p>
				
		<a href="http://www.135editor.com/users/index" title="授权微博后，文章将同步至微博的头条文章。" target="_blank"><img src="http://image.135editor.com/files/users/0/1/201610/hUZspbKr_SNIj.jpg"></a>
	</div>-->
	
{{$this->Form->end()}}

</div>
